package com.muzi.weshop.view.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.muzi.weshop.R;
import com.muzi.weshop.model.AddressModel;
import com.muzi.weshop.model.AdressListModel;

import java.util.List;

import butterknife.ButterKnife;

/**
 * @author logcat
 */
public class AddressAdapter extends BaseQuickAdapter<AdressListModel, BaseViewHolder> {

    private OnItemClickListener onItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public AddressAdapter(int layoutResId, @Nullable List<AdressListModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AdressListModel item) {
        helper.setText(R.id.tvAddress , item.getAdress());
        helper.itemView.findViewById(R.id.llAddressContainer).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onItemClickListener != null){
                    onItemClickListener.onItemClick(item.getId());
                }
            }
        });
    }


    public interface OnItemClickListener{
        void onItemClick(int id);
    }
}
